package images_api

import (
	"github.com/gin-gonic/gin"
	"gvb_server/global"
	"gvb_server/models"
	"gvb_server/models/res"
)

type ImageEditRequest struct {
	ID   uint   `json:"id" binding:"required" msg:"请选择文件id"`
	Name string `json:"name" binding:"required" msg:"请输入文件名称"`
}

func (ImagesApi) ImageEdit(c *gin.Context) {
	var edit ImageEditRequest
	err := c.ShouldBindJSON(&edit)
	if err != nil {
		res.FailWithError(err, &edit, c)
		return
	}
	err = global.DB.Updates(&models.BannerModel{Model: models.Model{ID: edit.ID}, Name: edit.Name}).Error
	if err != nil {
		res.Fail(err.Error(), c)
		return
	}
	res.OkWithMessage("图片修改成功", c)
}
